Exemple #1
0
    public CQ_Value Execute(string script)
    {
        var      expr  = CQ_Compiler.CompileParagraph(script); //语法分析
        CQ_Value value = expr.ComputeValue(content);           //执行表达式

        return(value);
    }
    protected override void Initialize()
    {
        switch (m_codeType)
        {
        case ECodeType.FileName:
            break;

        case ECodeType.TextAsset:
            CQ_Compiler.CompileOneFile(m_className, m_ta.text);
            break;

        case ECodeType.Text:
            CQ_Compiler.CompileOneFile(m_className, m_codeText);
            break;
        }

        type = CQuark.AppDomain.GetTypeByKeywordQuiet(m_className);
        if (type == null)
        {
            Debug.LogError("Type:" + m_className + "不存在与脚本项目中");
            return;
        }
        cclass  = type._class as Class_CQuark;
        content = CQ_ObjPool.PopContent();

        //TODO 最好在编译的时候就做,不要在实例化的时候做
        RegisterMember("gameObject", typeof(GameObject));
        RegisterMember("transform", typeof(Transform));

        inst = type._class.New(content, new CQuark.CQ_Value[0]).GetObject() as CQuark.CQ_ClassInstance;

        SetMember("gameObject", typeof(GameObject), this.gameObject);
        SetMember("transform", typeof(Transform), this.transform);


        if (cclass.functions.ContainsKey("Update"))
        {
            m_update = cclass.functions["Update"].expr_runtime;
        }
        if (cclass.functions.ContainsKey("FixedUpdate"))
        {
            m_fixedpdate = cclass.functions["FixedUpdate"].expr_runtime;
        }
    }
Exemple #3
0
    public IEnumerator StartCoroutine(string script, UnityEngine.MonoBehaviour coroutine)
    {
        var expr = CQ_Compiler.CompileParagraph(script);        //语法分析

        yield return(coroutine.StartCoroutine(expr.CoroutineCompute(content, coroutine)));
    }
 public void CompileNew()
 {
     m_tokens = CQ_Compiler.CompileOneFile("", m_text) as List <Token>;
 }