[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11182: Stop faking classes so that
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11182: Stop faking classes so that error reporting is more accurate; it's not |
Date: |
Mon, 29 Jun 2009 16:02:14 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11182
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-06-29 16:02:14 +0200
message:
Stop faking classes so that error reporting is more accurate; it's not
necessary for passing current testcases any more.
modified:
libcore/asMethod.h
libcore/parser/abc_block.cpp
------------------------------------------------------------
revno: 11179.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-06-29 15:20:06 +0200
message:
Add note about method return type. Don't fail on unknown return type, as
Gnash is doing this wrong. Don't fail on unknown parameter type; Gnash may
not be doing this wrong, but it is unhelpful. Log and continue.
modified:
libcore/asMethod.h
libcore/parser/abc_block.cpp
------------------------------------------------------------
revno: 11179.1.5
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-06-29 15:41:27 +0200
message:
Document semantic of passing 0 to pushArgument.
modified:
libcore/asMethod.h
------------------------------------------------------------
revno: 11179.1.6
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-06-29 15:42:31 +0200
message:
Comment on return type.
modified:
libcore/asMethod.h
------------------------------------------------------------
revno: 11179.1.7
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-06-29 15:43:36 +0200
message:
Improve parsing algorithm slightly. Minor cleanups and improved logging.
modified:
libcore/parser/abc_block.cpp
=== modified file 'libcore/asMethod.h'
--- a/libcore/asMethod.h 2009-06-23 07:15:40 +0000
+++ b/libcore/asMethod.h 2009-06-29 13:42:31 +0000
@@ -143,6 +143,12 @@
asClass* getReturnType() const;
/// Set the return type
+ //
+ /// TODO: This is currently a no-op, so find out what it's for and
+ /// implement it.
+ /// NB: the return type of a method can be * (any) or void, neither of
+ /// which are asClasses, so this may not be an appropriate way to
+ /// handle return type.
void setReturnType(asClass* t);
asMethod *getSuper();
@@ -182,48 +188,43 @@
void setProtected() {
_flags = (_flags & ~(FLAGS_PUBLIC | FLAGS_PRIVATE)) | FLAGS_PROTECTED;
}
- /// \brief
/// Is the method public?
bool isPublic() const { return _flags & FLAGS_PUBLIC; }
- /// \brief
/// Make the method public.
void setPublic() {
_flags = (_flags & ~(FLAGS_PRIVATE | FLAGS_PROTECTED)) | FLAGS_PUBLIC;
}
- /// \brief
/// How many arguments are required? -1 means unknown.
int minArgumentCount() const { return _minArguments; }
- /// \brief
/// Set the required minimum arguments.
void setMinArgumentCount(int i) { _minArguments = i; }
- /// \brief
/// How many arguments are allowed? -1 means unknown.
int maxArgumentCount() const { return _maxArguments; }
/// Set the required maximum arguments.
void setMaxArgumentCount(int i) { _maxArguments = i; }
- /// \brief
/// Push an argument of type t into the method definition
- void pushArgument(asClass *t) { _arguments.push_back(t); }
+ //
+ /// A value of 0 stands for 'any'.
+ void pushArgument(asClass* t) { _arguments.push_back(t); }
- /// \brief
/// Push an optional argument's default value.
void pushOptional(const as_value& v) { _optionalArguments.push_back(v);
}
- /// \brief
/// Are any of the arguments optional?
bool optionalArguments() const {
return minArgumentCount() != maxArgumentCount();
}
- /// \brief
/// Get a reference to a list of argument types.
- ArgumentList& getArgumentList() { return _arguments; }
+ //
+ /// NB: Some values may be 0, meaning "any".
+ const ArgumentList& getArgumentList() const { return _arguments; }
/// \brief
/// Get an object capable of executing this function.
=== modified file 'libcore/parser/abc_block.cpp'
--- a/libcore/parser/abc_block.cpp 2009-06-29 12:27:22 +0000
+++ b/libcore/parser/abc_block.cpp 2009-06-29 13:43:36 +0000
@@ -241,8 +241,7 @@
boost::uint32_t offset = in->read_V32();
log_abc("Method index=%u", offset);
- if (offset >= pBlock->_methods.size())
- {
+ if (offset >= pBlock->_methods.size()) {
log_error(_("Bad method id in trait."));
return false;
}
@@ -268,8 +267,7 @@
{
_slotID = in->read_V32();
boost::uint32_t offset = in->read_V32();
- if (offset >= pBlock->_methods.size())
- {
+ if (offset >= pBlock->_methods.size()) {
log_error(_("Bad method id in trait."));
return false;
}
@@ -437,24 +435,8 @@
}
// One last chance: Look globally.
found = mCH->getGlobalNs()->getClass(m.getABCName());
- if (found)
- return found;
+ return found;
- // Fake it here for a while.
- if (m.getNamespace())
- {
- m.getNamespace()->stubPrototype(m.getABCName());
- found = m.getNamespace()->getClass(m.getABCName());
- return found;
- }
- else
- {
- // Fake in global.
- mCH->getGlobalNs()->stubPrototype(m.getABCName());
- found = mCH->getGlobalNs()->getClass(m.getABCName());
- return found;
- }
- return NULL;
}
/// Read the ActionBlock version number.
@@ -561,9 +543,8 @@
log_abc("Namespace %u: kind %s, index %u, name %s", i,
static_cast<int>(kind), nameIndex, _stringPool[nameIndex]);
- if (nameIndex >= _stringPool.size())
- {
- log_error(_("ABC: Out of bounds string given for
namespace."));
+ if (nameIndex >= _stringPool.size()) {
+ log_error(_("ABC: Bad string given for namespace."));
return false;
}
@@ -604,7 +585,7 @@
boost::uint32_t selection = _stream->read_V32();
if (!selection || selection >= _namespacePool.size())
{
- log_error(_("ABC: Out of bounds namespace for
namespace set."));
+ log_error(_("ABC: Bad namespace for namespace
set."));
return false;
}
_namespaceSetPool[i][j] = _namespacePool[selection];
@@ -796,54 +777,68 @@
boost::uint32_t param_count = _stream->read_V32();
boost::uint32_t return_type = _stream->read_V32();
- log_abc(" Param count: %u return type(index): %s(%u)",
param_count,
- _stringPool[_multinamePool[return_type].getABCName()],
- return_type);
+ const std::string& rt = return_type ?
+ _stringPool[_multinamePool[return_type].getABCName()] :
+ "*";
+
+ log_abc(" Param count: %u, return type: %s", param_count,
+ rt, return_type);
pMethod->setMinArgumentCount(param_count);
pMethod->setMaxArgumentCount(param_count);
- if (return_type >= _multinamePool.size())
- {
- log_error(_("ABC: Out of bounds return type for method
info."));
- return false;
- }
- asClass *rtClass = locateClass(_multinamePool[return_type]);
- if (!rtClass)
- {
- log_error(_("ABC: Unknown return type."));
- return false;
- }
-
- pMethod->setReturnType(rtClass);
-
- for (unsigned int j = 0; j < param_count; ++j)
- {
+ if (return_type >= _multinamePool.size()) {
+ log_error(_("ABC: Bad return type for method info."));
+ return false;
+ }
+
+ if (!return_type) {
+ pMethod->setReturnType(0);
+ }
+ else {
+ // TODO: this can be 'void', which clearly isn't a class, so this
+ // seems bogus. As setReturnType is a no-op, we should log it
+ // and ignore it.
+ asClass* rtClass = locateClass(_multinamePool[return_type]);
+ if (!rtClass) {
+ log_abc(_("ABC: Unknown return type."));
+ }
+
+ pMethod->setReturnType(rtClass);
+ }
+ for (size_t j = 0; j < param_count; ++j) {
log_abc(" Reading parameter %u", j);
// The parameter type.
boost::uint32_t ptype = _stream->read_V32();
- log_abc(" Parameter type(index): %s(%u)",
- _stringPool[_multinamePool[ptype].getABCName()], ptype);
-
- if (ptype >= _multinamePool.size())
- {
- log_error(_("ABC: Out of bounds parameter type
in method."));
- return false;
- }
- asClass *param_type =
locateClass(_multinamePool[ptype]);
-// log_abc("Done creating asClass object.");
- if (!param_type)
- {
- log_error((_("ABC: Unknown parameter type.")));
- return false;
- }
-// log_abc("Trying to add argument to method.");
- pMethod->pushArgument(param_type);
-// log_abc("Done adding argument to method object.");
+
+ const std::string& pt = return_type ?
+ _stringPool[_multinamePool[ptype].getABCName()] :
+ "*";
+
+ log_abc(" Parameter type(index): %s(%u)", pt, ptype);
+
+ if (ptype >= _multinamePool.size()) {
+ log_error(_("ABC: Bad parameter type in
method."));
+ return false;
+ }
+
+ // A value of 0 is legitimate, meaning 'any (*)'.
+ if (ptype) {
+ asClass* param_type = locateClass(_multinamePool[ptype]);
+
+ if (!param_type) {
+ log_abc((_("ABC: Unknown parameter type.")));
+ }
+
+ // This currently also pushes 0, meaning 'any'; perhaps it
+ // should throw a VerifyError if the class is not known.
+ pMethod->pushArgument(param_type);
+ }
+ else {
+ pMethod->pushArgument(0);
+ }
}
-// log_abc("End loop j.");
- // A skippable name index.
-// _stream->skip_V32();
+
boost::uint32_t method_name = _stream->read_V32();
log_abc( "Method name=%s %d", _stringPool[method_name],
method_name);
boost::uint8_t flags = _stream->read_u8();
@@ -946,7 +941,7 @@
boost::uint32_t super_index = _stream->read_V32();;
if (super_index && super_index >= _multinamePool.size())
{
- log_error(_("ABC: Out of bounds super type."));
+ log_error(_("ABC: Bad super type."));
return false;
}
if (!super_index)
@@ -1005,7 +1000,7 @@
if (flags & INSTANCE_PROTECTED_NS) {
boost::uint32_t ns_index = _stream->read_V32();
if (ns_index >= _namespacePool.size()) {
- log_error(_("ABC: Out of bounds namespace for
protected."));
+ log_error(_("ABC: Bad namespace for
protected."));
return false;
}
// Set the protected namespace's parent, if it exists.
@@ -1024,7 +1019,7 @@
log_abc("Interface %u has multiname index=%u", i,
i_index);
// 0 is allowed as an interface, typically for the last
one.
if (i_index >= _multinamePool.size()) {
- log_error(_("ABC: Out of bounds name for
interface."));
+ log_error(_("ABC: Bad name for interface."));
return false;
}
asClass *pInterface =
locateClass(_multinamePool[i_index]);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11182: Stop faking classes so that error reporting is more accurate; it's not,
Benjamin Wolsey <=