public class methods
This commit is contained in:
		
							parent
							
								
									3ef80616d8
								
							
						
					
					
						commit
						f338c54632
					
				@ -715,7 +715,6 @@ class Compiler(
 | 
			
		||||
        cc.skipTokenOfType(Token.Type.NEWLINE, isOptional = true)
 | 
			
		||||
        val t = cc.next()
 | 
			
		||||
 | 
			
		||||
        var extraInit: Statement? = null
 | 
			
		||||
        val bodyInit: Statement? = if (t.type == Token.Type.LBRACE) {
 | 
			
		||||
            // parse body
 | 
			
		||||
            parseScript(t.pos, cc).also {
 | 
			
		||||
@ -728,7 +727,6 @@ class Compiler(
 | 
			
		||||
 | 
			
		||||
        // create class
 | 
			
		||||
        val className = nameToken.value
 | 
			
		||||
        lateinit var classContext: Context
 | 
			
		||||
 | 
			
		||||
        @Suppress("UNUSED_VARIABLE") val defaultAccess = if (isStruct) AccessType.Var else AccessType.Initialization
 | 
			
		||||
        @Suppress("UNUSED_VARIABLE") val defaultVisibility = Visibility.Public
 | 
			
		||||
 | 
			
		||||
@ -27,6 +27,7 @@ class Context(
 | 
			
		||||
 | 
			
		||||
    fun raiseClassCastError(msg: String): Nothing = raiseError(ObjClassCastError(this, msg))
 | 
			
		||||
 | 
			
		||||
    @Suppress("unused")
 | 
			
		||||
    fun raiseSymbolNotFound(name: String): Nothing = raiseError(ObjSymbolNotDefinedError(this, "symbol is not defined: $name"))
 | 
			
		||||
 | 
			
		||||
    fun raiseError(message: String): Nothing {
 | 
			
		||||
@ -78,7 +79,7 @@ class Context(
 | 
			
		||||
 | 
			
		||||
    fun getOrCreateNamespace(name: String): ObjClass {
 | 
			
		||||
        val ns = objects.getOrPut(name) { ObjRecord(ObjNamespace(name), isMutable = false) }.value
 | 
			
		||||
        return ns!!.objClass
 | 
			
		||||
        return ns.objClass
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    inline fun addVoidFn(vararg names: String, crossinline fn: suspend Context.() -> Unit) {
 | 
			
		||||
 | 
			
		||||
@ -46,7 +46,7 @@ class ObjClass(
 | 
			
		||||
    ) {
 | 
			
		||||
        if (name in members || allParentsSet.any { name in it.members } == true)
 | 
			
		||||
            throw ScriptError(pos, "$name is already defined in $objClass or one of its supertypes")
 | 
			
		||||
        members[name] = ObjRecord(initialValue, isMutable)
 | 
			
		||||
        members[name] = ObjRecord(initialValue, isMutable, visibility)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun addFn(name: String, isOpen: Boolean = false, code: suspend Context.() -> Obj) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user