mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 15:15:37 +00:00
Issue #181: assignment to member variables
This commit is contained in:
parent
10b27e582b
commit
fe85de5ea7
3 changed files with 42 additions and 5 deletions
|
@ -113,12 +113,13 @@ namespace Compiler
|
||||||
if (mState==SetState)
|
if (mState==SetState)
|
||||||
{
|
{
|
||||||
std::string name2 = toLower (name);
|
std::string name2 = toLower (name);
|
||||||
|
mName = name2;
|
||||||
|
|
||||||
// local variable?
|
// local variable?
|
||||||
char type = mLocals.getType (name2);
|
char type = mLocals.getType (name2);
|
||||||
if (type!=' ')
|
if (type!=' ')
|
||||||
{
|
{
|
||||||
mName = name2;
|
mType = type;
|
||||||
mState = SetLocalVarState;
|
mState = SetLocalVarState;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -126,12 +127,27 @@ namespace Compiler
|
||||||
type = getContext().getGlobalType (name2);
|
type = getContext().getGlobalType (name2);
|
||||||
if (type!=' ')
|
if (type!=' ')
|
||||||
{
|
{
|
||||||
mName = name2;
|
|
||||||
mType = type;
|
mType = type;
|
||||||
mState = SetGlobalVarState;
|
mState = SetGlobalVarState;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mState = SetPotentialMemberVarState;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mState==SetMemberVarState)
|
||||||
|
{
|
||||||
|
mMemberName = toLower (name);
|
||||||
|
char type = getContext().getMemberType (mMemberName, mName);
|
||||||
|
|
||||||
|
if (type!=' ')
|
||||||
|
{
|
||||||
|
mState = SetMemberVarState2;
|
||||||
|
mType = type;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
getErrorHandler().error ("unknown variable", loc);
|
getErrorHandler().error ("unknown variable", loc);
|
||||||
SkipParser skip (getErrorHandler(), getContext());
|
SkipParser skip (getErrorHandler(), getContext());
|
||||||
scanner.scan (skip);
|
scanner.scan (skip);
|
||||||
|
@ -338,6 +354,19 @@ namespace Compiler
|
||||||
mState = EndState;
|
mState = EndState;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (mState==SetMemberVarState2 && keyword==Scanner::K_to)
|
||||||
|
{
|
||||||
|
mExprParser.reset();
|
||||||
|
scanner.scan (mExprParser);
|
||||||
|
|
||||||
|
std::vector<Interpreter::Type_Code> code;
|
||||||
|
char type = mExprParser.append (code);
|
||||||
|
|
||||||
|
Generator::assignToMember (mCode, mLiterals, mType, mMemberName, mName, code, type);
|
||||||
|
|
||||||
|
mState = EndState;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mAllowExpression)
|
if (mAllowExpression)
|
||||||
{
|
{
|
||||||
|
@ -392,6 +421,12 @@ namespace Compiler
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (code==Scanner::S_member && mState==SetPotentialMemberVarState)
|
||||||
|
{
|
||||||
|
mState = SetMemberVarState;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mAllowExpression && mState==BeginState &&
|
if (mAllowExpression && mState==BeginState &&
|
||||||
(code==Scanner::S_open || code==Scanner::S_minus))
|
(code==Scanner::S_open || code==Scanner::S_minus))
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,8 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
BeginState,
|
BeginState,
|
||||||
ShortState, LongState, FloatState,
|
ShortState, LongState, FloatState,
|
||||||
SetState, SetLocalVarState, SetGlobalVarState,
|
SetState, SetLocalVarState, SetGlobalVarState, SetPotentialMemberVarState,
|
||||||
|
SetMemberVarState, SetMemberVarState2,
|
||||||
MessageState, MessageCommaState, MessageButtonState, MessageButtonCommaState,
|
MessageState, MessageCommaState, MessageButtonState, MessageButtonCommaState,
|
||||||
EndState,
|
EndState,
|
||||||
PotentialExplicitState, ExplicitState, MemberState
|
PotentialExplicitState, ExplicitState, MemberState
|
||||||
|
@ -32,6 +33,7 @@ namespace Compiler
|
||||||
std::vector<Interpreter::Type_Code>& mCode;
|
std::vector<Interpreter::Type_Code>& mCode;
|
||||||
State mState;
|
State mState;
|
||||||
std::string mName;
|
std::string mName;
|
||||||
|
std::string mMemberName;
|
||||||
int mButtons;
|
int mButtons;
|
||||||
std::string mExplicit;
|
std::string mExplicit;
|
||||||
char mType;
|
char mType;
|
||||||
|
|
|
@ -252,9 +252,9 @@ namespace Interpreter
|
||||||
|
|
||||||
virtual void execute (Runtime& runtime)
|
virtual void execute (Runtime& runtime)
|
||||||
{
|
{
|
||||||
Type_Integer index = runtime[0].mInteger;
|
Type_Float data = runtime[0].mFloat;
|
||||||
|
Type_Integer index = runtime[1].mInteger;
|
||||||
std::string id = runtime.getStringLiteral (index);
|
std::string id = runtime.getStringLiteral (index);
|
||||||
Type_Float data = runtime[1].mFloat;
|
|
||||||
index = runtime[2].mInteger;
|
index = runtime[2].mInteger;
|
||||||
std::string variable = runtime.getStringLiteral (index);
|
std::string variable = runtime.getStringLiteral (index);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue