Exemplo n.º 1
0
        public bool CmdDefine(ScriptLine line)
        {
            if (!CheckSwitchBlock())
            {
                return(false);
            }
            var name  = string.Empty;
            var data  = string.Empty;
            int isNum = 0;

            line.Skip(" \t");
            if (!line.GetWord(ref name, " \t"))
            {
                //		Error("정의어 이름이 없습니다");
                Error("no define name");
                return(false);
            }

            line.Skip(" \t");
            if (line.GetParse(ref data, '"'))
            {
                isNum = 0;
            }
            else if (!GetDefVar(line, ref data, ref isNum))
            {
                //		Error("정의 선언 값 부분에 문제가 있습니다");
                Error("problem of define value");
                return(false);
            }

            m_tokenMap.Set(name, TOKENTYPE.TOKENTYPE_DEFINE, isNum, data);

            m_asm.Commentf("define {0} {1}", name, data);
            return(true);
        }
Exemplo n.º 2
0
        public bool Value(ScriptLine line, bool flag = true)
        {
            var data = string.Empty;
            var op   = string.Empty;

            while (true)
            {
                line.Skip(" \t[");
                if (line.GetParse(ref data, '"'))
                {
                    if (data.Length >= 250)
                    {
                        Error("Value: 250 strlen(data) >= 250 {0}", data);
                        return(false);
                    }
                    WriteStr(data);
                }
                else if (line.GetParse(ref data, '#'))
                {
                    TokenInfo tokenInfo;
                    if (!m_tokenMap.Get(data, out tokenInfo))
                    {
                        Error("Value: [{0}]  is not in a token map - GetParse", data);
                        return(false);
                    }
                    if (tokenInfo.num > 0)
                    {
                        WriteNum(Convert.ToInt32(tokenInfo.GetStr()));
                    }
                    else
                    {
                        WriteStr(tokenInfo.GetStr());
                    }
                }
                else if (line.GetWord(ref data, "%!=+-/*&|>< \t[],"))
                {
                    if (IsNum(data))
                    {
                        WriteNum(Convert.ToInt32(data));
                    }
                    else
                    {
                        TokenInfo tokenInfo;

                        if (!m_tokenMap.Get(data, out tokenInfo))
                        {
                            Error("Value: [{0}] is not in a token map - GetWord", data);
                            return(false);
                        }
                        switch (tokenInfo.type)
                        {
                        case TOKENTYPE.TOKENTYPE_VAR:
                            WriteVar(data);
                            break;

                        case TOKENTYPE.TOKENTYPE_DEFINE:
                            if (tokenInfo.num > 0)
                            {
                                WriteNum(Convert.ToInt32(tokenInfo.GetStr()));
                            }
                            else
                            {
                                WriteStr(tokenInfo.GetStr());
                            }
                            break;

                        case TOKENTYPE.TOKENTYPE_FUNC:
                            WriteCall(data);
                            if (!OnFunc(line, tokenInfo.num, tokenInfo.GetStr()))
                            {
                                Error("Value: Func not found");
                                return(false);
                            }
                            break;

                        default:
                        {
                            //						    Error("Value: %s 토큰은 사용될수 없습니다 line:%s", data, line.GetBase());
                            Error("Value: {0} tokenInfo->type not found line:{1}", data, line.GetBase());
                            return(false);
                        }
                        }
                    }
                }
                else
                {
                    //			if (flag) Error("Value:값이 없습니다 line:%s", line.GetBase());
                    return(false);
                }

                line.Skip(" \t,");
                if (!line.GetOperator(ref op, "%=+-/*&|><!"))
                {
                    break;
                }
                if (string.IsNullOrEmpty(op))
                {
                    break;
                }

                if (!WriteOp(op))
                {
                    Error("Value: write error!");
                    return(false);
                }
            }
            line.Skip("]");
            WriteOp(";");
            return(true);
        }