示例#1
0
 private bool buildConstructor(Token token, EnegyData data)
 {
     Method cm = new Method(null);
     token.next();
     cm.SetAgumentStack(AgumentParser.parseAguments(token, db, data));
     cm.SetBody(new CallScriptMethod(cm.GetAgumentStack(), BodyParser.parse(token, data, db)).call);
     cm.SetVariabel();
     builder.SetConstructor(cm, data, db, token.getCache().posision());
     token.next();
     return true;
 }
示例#2
0
        private bool buildMethod(ClassItemAccessLevel level, bool isStatic, Token token, EnegyData data)
        {
            //control if there are is name after function :)
            if (token.getCache().type() != TokenType.Variabel)
            {
                data.setError(new ScriptError("A method should have a name", token.getCache().posision()), db);
                return false;
            }

            string type = null;

            //okay the name can be a type so wee control it here :)
            if (Types.IsType(token.getCache().ToString(), db))
            {
                type = token.getCache().ToString();

                if(token.next().type() != TokenType.Variabel)
                {
                    data.setError(new ScriptError("A method should have a name", token.getCache().posision()), db);
                    return false;
                }
            }

            Method method = new Method(token.getCache().ToString());

            token.next();

            if (isStatic)
                method.SetStatic();

            method.SetAgumentStack(AgumentParser.parseAguments(token, db, data));
            method.SetBody(new CallScriptMethod(method.GetAgumentStack(), BodyParser.parse(token, data, db)).call);
            method.SetVariabel();//in this way the script can use agument as name :)
            method.setLevel(level);

            builder.SetMethod(method, data, db, token.getCache().posision());
            token.next();
            return true;
        }